package com.qs.eggs.view.prodetail.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RatingBar;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.qs.eggs.R;
import com.qs.eggs.bean.EvaluationBean;
import com.qs.eggs.refresh.adapter.BaseRecyclerAdapter;


public class EvaluationAdapter extends BaseRecyclerAdapter<EvaluationBean> implements BaseRecyclerAdapter.OnLoadingHeaderCallBack {


    public EvaluationAdapter(Context context, int mode) {
        super(context, mode);

        setOnLoadingHeaderCallBack(this);
    }

    @Override
    public RecyclerView.ViewHolder onCreateHeaderHolder(ViewGroup parent) {
        return new HeaderViewHolder(mHeaderView);
    }

    @Override
    public void onBindHeaderHolder(RecyclerView.ViewHolder holder, int position) {

    }

    @Override
    protected RecyclerView.ViewHolder onCreateDefaultViewHolder(ViewGroup parent, int type) {
        return new SortViewHolder(mInflater.inflate(R.layout.item_evaluation, parent, false));
    }

    @Override
    protected void onBindDefaultViewHolder(RecyclerView.ViewHolder holder, EvaluationBean item, int position) {
        final SortViewHolder vh = (SortViewHolder) holder;

        vh.mUserName.setText(item.getCustname());
        vh.mPubDate.setText(item.getCreatetime());
        vh.mComment.setText(item.getComments());
        vh.ratingBar.setRating(Float.valueOf(item.getScores()));
       // vh.mAvatar.setImageURI(Constants.URL_BASE+"productimages/"+item.getAutoname());

    }
    private static class SortViewHolder extends RecyclerView.ViewHolder {
        TextView mUserName,mPubDate,mComment;
        RatingBar ratingBar;
        ImageView mCollect;
        SimpleDraweeView mAvatar;


        public SortViewHolder(View itemView) {
            super(itemView);

            mUserName=(TextView) itemView.findViewById(R.id.tv_comment_user);
            mPubDate=(TextView) itemView.findViewById(R.id.tv_comment_date);
            mComment=(TextView) itemView.findViewById(R.id.tv_comment);
            ratingBar=(RatingBar)itemView.findViewById(R.id.room_ratingbar);
            mAvatar=(SimpleDraweeView) itemView.findViewById(R.id.propic);
        }
    }
}
